﻿using DevExpress.Charts.Model;
using DevExpress.Xpf.Charts;
using HandyControl.Controls;
using ImTools;
using PlaceOrder_Client.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Color = System.Windows.Media.Color;
using UserControl = System.Windows.Controls.UserControl;

namespace PlaceOrder_Client.Views
{
    /// <summary>
    /// TransactionReviewView.xaml 的交互逻辑
    /// </summary>
    public partial class TransactionReviewView : UserControl
    {
        public TransactionReviewView()
        {
            InitializeComponent();
        }
        private void CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e)
        {
            var dataPoint = e.SeriesPoint.Argument; // 替换成您实际的数据类型

            int data = (int.Parse)(dataPoint);
            if (dataPoint != null)
            {
                // 根据数据对象的属性设置柱形的颜色
                if (data < 0)
                {
                    e.DrawOptions.Color = Colors.Green; // 设置柱形的颜色为绿色
                }
                else
                {
                    e.DrawOptions.Color = Colors.Red; // 设置柱形的颜色为绿色
                }
            }
        }

        private void chartControl_CustomDrawSeries(object sender, CustomDrawSeriesPointEventArgs e)
        {
            DrawOptions op = e.DrawOptions as DrawOptions; //修改柱状图和饼状图颜色
            if (op != null)
            {
                int val =(int)e.SeriesPoint.Value;
                if (val>0)
                    op.Color = Color.FromRgb(255, 0, 0);
                else 
                    op.Color = Color.FromRgb(74,232,121);
            }

        }

        private void BarSeries_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
           
            // 在这里添加你的逻辑
        }

        private void chartControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var hitInfo = chartControl.CalcHitInfo(e.GetPosition(chartControl));

            if (hitInfo.SeriesPoint == null)
                return;

            if (hitInfo.Series.Name == "bar1") // 替换为你的系列名称
            {
                // 获取Argument及value等信息并显示
                Growl.InfoGlobal(hitInfo.SeriesPoint.Value.ToString());
            }
        }
    }
}
